package ac.framework.ui.shadowed.white;

import java.awt.Color;
import java.awt.GradientPaint;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Paint;
import java.awt.geom.Rectangle2D;

import javax.swing.Icon;

public class WhiteGradientLabel extends WhiteLabel 
{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
    private boolean reverseGradient					= false;
	private Color upperColor								= Color.LIGHT_GRAY;
	private Color lowerColor								= Color.WHITE;
    
	
	public WhiteGradientLabel() {
		super();
	}

	public WhiteGradientLabel(Icon arg0, int arg1) {
		super(arg0, arg1);
	}

	public WhiteGradientLabel(Icon arg0) {
		super(arg0);
	}

	public WhiteGradientLabel(String arg0, Icon arg1, int arg2) {
		super(arg0, arg1, arg2);
	}

	public WhiteGradientLabel(String arg0, int arg1) {
		super(arg0, arg1);
	}

	public WhiteGradientLabel(String arg0) {
		super(arg0);
	}

	/* (non-Javadoc)
	 * @see javax.swing.JComponent#printComponent(java.awt.Graphics)
	 */
	@Override
	protected void paintComponent(Graphics g) 
	{
		
		Graphics2D g2d = (Graphics2D) g;
		Paint oldPaint = g2d.getPaint();
		
		GradientPaint  paint = new GradientPaint(0,0,upperColor, 0,getHeight(),lowerColor);
		g2d.setPaint(paint);
		
		g2d.fill(new Rectangle2D.Double(0, 0, getWidth(), getHeight()));
		
		g2d.setPaint(oldPaint);
		super.setOpaque(false);
		super.paintComponent(g);
	}

	/**
	 * @return the reverseGradient
	 */
	public boolean isReverseGradient() {
		return reverseGradient;
	}

	/**
	 * @param reverseGradient the reverseGradient to set
	 */
	public void setReverseGradient(boolean reverseGradient) {
		this.reverseGradient = reverseGradient;
		if(reverseGradient)
		{
			Color temp 							= upperColor;
			upperColor								= lowerColor;
			lowerColor								= temp;			
		}
		else
		{
			Color temp 							= upperColor;
			upperColor								= lowerColor;
			lowerColor								= temp;			
		}
		repaint();
	}

	/**
	 * @return the upperColor
	 */
	public Color getUpperColor() {
		return upperColor;
	}

	/**
	 * @return the lowerColor
	 */
	public Color getLowerColor() {
		return lowerColor;
	}

	/**
	 * @param upperColor the upperColor to set
	 */
	public void setUpperColor(Color upperColor) {
		this.upperColor = upperColor;
	}

	/**
	 * @param lowerColor the lowerColor to set
	 */
	public void setLowerColor(Color lowerColor) {
		this.lowerColor = lowerColor;
	}
	
	

}
